package com.itheima.controller;

import com.itheima.po.Orders;
import com.itheima.po.R;
import com.itheima.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Andy
 * @Description //TODO OrdersController
 * @Date 2022/3/19 2:46 下午
 * @Version 1.0
 **/
@RestController
@RequestMapping("/order")
public class OrdersController {

//    Request URL: http://localhost:8080/order/submit
//    Request Method: POST
//    body :{"remark":"","payMethod":1,"addressBookId":"1505004591069016065"}
// 操作两张表 要在一个事务内 所以需要定义一个service方法来实现

    @Autowired
    private OrdersService ordersService;

    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        ordersService.submit(orders);
        return R.success("下单成功");
    }
}
